<form action="" class="form-horizontal" role="form">
	<div class="form-group">
	    <label class="col-sm-2 control-label">排列序号</label>
	    <div class="col-sm-2">
	      <input type="number" class="form-control" name="sort" min="0" placeholder="" datatype="n" value="{$wechatMenu.sort}">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-sm-2 control-label">上级菜单</label>
	    <div class="col-sm-2">
	      <select class="form-control" name="pid">{$topMenuOptions}</select>
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-sm-2 control-label">菜单名称</label>
	    <div class="col-sm-2">
	      <input type="text" class="form-control" name="name" placeholder="菜单名称" datatype="*1-10" value="{$wechatMenu.name}">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-sm-2 control-label">回复类型</label>
	    <div class="col-sm-2">
	      <select class="form-control" id="type" name="type">{$menuTypesOptions}</select>
	    </div>
	</div>
	<div class="form-group" id="menu_url" style="display:none;">
		<label class="col-sm-2 control-label">链接地址</label>
		<div class="col-sm-6">
			<input type="text" class="form-control" name="url" placeholder="菜单的链接地址" value="{$wechatMenu.url}">
		</div>
	</div>
	<div class="form-group" id="menu_key" style="display:none;">
		<label class="col-sm-2 control-label">回复关键词</label>
		<div class="col-sm-3">
			<input type="text" class="form-control" name="key" placeholder="回复关键词" value="{$wechatMenu.key}" style="width:70%;float:left;">&nbsp;
			<a id="btnKey" class="btn btn-info" href="#">修改</a>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-8">
			<input type="hidden" name="id" value="{$wechatMenu.id}"/>
			<button type="submit" class="btn btn-primary" data-loading-txt="提交中，请稍后……" data-ajax-url="__CONTROLLER__/save">保存更改</button>
		</div>
	</div>
</form>

<script type="text/javascript" >

function openWin(name, url) {
	if( $("#"+name).size() == 0 ) {
		var window = "<div id=\""+ name +"\" style=\"width:100%;height:100%;position:absolute;top:0px;left:0px;\" >" +
			"<iframe id=\""+ name +"Frame\" src=\""+ url +"\" style=\"width:100%;height:100%\"></iframe>" +
		 "</div>";
		$(document.body).append(window);
	} else {
		 $("#"+name).find("#"+name+"Frame").attr('src', url);
		 $("#"+name).show();
	}
}
$("#btnKey").click(function() {
	openWin("winReply", "/index.php/Partner/WechatReply/menu/handle/winReply/keyword/"+$("input[name='key']").val());
	return false;
});

$("#type").change(function() {
	var sel = $(this).val();
	if (sel == "url") {
		$("#menu_url").show();
		$("#menu_key").hide()
	} else if(sel == "key") {
		$("#menu_url").hide();
		$("#menu_key").show();
	} else {
		$("#menu_url").hide();
		$("#menu_key").hide()
	}
});
$("#type").change();
</script>